<html>
    <head>
        <meta charset="UTF-8">
        <link rel="stylesheet" href="https://cdn.staticfile.org/layui/2.6.8/css/layui.min.css"   />
        <link rel="stylesheet" href="../../res/css/mz.css" />
        <script src="https://cdn.staticfile.org/layui/2.6.8/layui.min.js" ></script>
        <script type="text/javascript" charset="utf-8" src="../../ueditor_res/ueditor.config.js"></script>
        <script type="text/javascript" charset="utf-8" src="../../ueditor_res/ueditor.all.js"> </script>
        <script type="text/javascript" charset="utf-8" src="../../ueditor_res/lang/zh-cn/zh-cn.js"></script>
        <script src="../../res/js/mz.form.js"></script>
        <script src="../../res/js/mz.common.js"></script>
    </head>
    <body>

        <div style=" margin: 10px auto;">
            <form id="data_form"  class="layui-form layui-form-pane">

            </form>


        </div>


        <script>

            var field_setting = [
                {title: '编号', name: 'id', type: 'hidden'},
                {title: '标题', name: 'title', type: 'text'},
                {title: '作者', name: 'author', type: 'text'},
                {title: '简介', name: 'introduction', type: 'textarea'},
                {title: '发布时间', name: 'publish_time', type: 'text'},
                {title: '内容', name: 'content', type: 'html', content: '<label class="layui-form-label">内容</label><div class="layui-input-block"><div id="editor" name="content" style="height: 500px;"></div></div>'},
                {title: '附件', name: 'attachment', type: 'file', url: '/file/upload', multiple: true},
                {title: '附件2', name: 'attachments', type: 'file', url: '/file/upload', multiple: true}
            ];

            field_setting.push({type: 'buttons', name: 'submit'});

            var id = getQueryString('id');

            var mzForm = new MZForm({
                id: 'data_form',
                elements: field_setting,
                data_url: id ? (base_url + '/article_one_query/' + id) : null,
                data_loaded: function(data){
                    UE.getEditor('editor').setContent(data.content || '');
                },
                submit:{
                    post_url: base_url + '/article_post',
                    put_url: base_url + '/article_put',
                    success_url: 'list.html'
                }
            });

            UE.getEditor('editor');

        </script>

    </body>
</html>
